Verilog基础(二) | 您所在的位置:网站首页 › verilog 头文件可综合吗 › Verilog基础(二) |
二、Verilog指南
(1)模块化设计
模块是Verilog的基本描述单位,用于描述某个设计的功能或结构及其与其他模块通信的外部端口。一个设计的结构可使用开关级原语、门级原语和用户定义的原语方式描述;设计的 数据流行为使用连续赋值语句进行描述;时序行为使用过程结构描述。一个模块可在另一个 模块中使用。 (2)代码规范(华为)1、RTL CODE 规范 1.1标准的文件头 在每一个版块的开头一定要使用统一的文件头,其中包括作者名,模块名,创建日期,概要,更改记录,版权等必要信息。 统一使用以下的文件头: // ************************************************************** // COPYRIGHT(c)2005, Hislicon Technologies Co, Ltd // All rights reserved. // // IP LIB INDEX : IP lib index just sa UTOPIA_B // IP Name : the top module_name of this ip, usually, is same // as the small ip classified name just as UTOPIA // File name : file_name of the file just as “tx_fifo.v” // Module name : module_name of this file just as “TX_FIFO” // Full name : complete Emglish nme of this abbreviated // // Author : Athor/ID // Email : Author’s email // Data : // Version : V 1.0 // //Abstract : // Called by : Father Module // // Modification history // ------------------------------------------------------------------------------------------------------ // // // $Log$ // // ********************************************************************* 1.2. 标准的module 格式 (module 整体结构) 对于模块的书写采用统一的格式便于项目内部成员的理解和维护,我们用批处理建立了一个MODULE模块,其内容解释如下: 端口定义按照输入,输出,双向的顺序:模块名、模块例化名统一,例化名前加大写U_以区分 ( 多次例化另加标识 ),三者关系:文件名 :xxx .v (小写) 模块名 :XXX (大写) 例化名 :U_XXX (大写) IP 内部所有的模块名都要加IP名或者IP名简称作前缀,如USB_CTRL、USB_TX_FIFO。 // ***************************** // DEFINE MODULE PORT // // ****************************** // // module MODULE_NAME ( // INPUT input_port_1, … input_port_m, // OUTPUT output_port_1, … output_port_m, ); // ***************************** // DEFINE PARAMETER // // ****************************** parameter… // ****************************** // DEFINE INPUT // ****************************** input rst_n ; // reset, active low . input clk_* ; // clock signal , 50M . input [n:0] a_din ; // ***** input [k:0] b_din ; // ***** // ****************************** // DEFINE OUTPUT // // ****************************** output [m:0] a_dout ; // ***** output [i:0] b_dout ; // ***** // ****************************** // OUTPUT ATRRIBUTE // // ****************************** // REGS reg [m:0] a_dout ; // ***** //WIRES wire [i:0] b_dout ; // *****
// ****************************** // INSTSNCE MODULE // // ****************************** MODULE_NAME_A U_MODULE_NAME_A( .A (A ), .B (B ), .C (C ), ); … // ****************************** //MAIN CODE // // ****************************** … … … … … … // ****************************** // Endmodule 1.3.一致的排版 A. 一致的缩排 统一的缩排取4个空格宽度输入输出信号的宽度定义与关键字之间,信号名与宽度之间要用空格分开;所有宽度定义对所有信号名对齐,代码风格统一如下:input [3:0] input_a ; // ***** input input_b ; // ***** … output [128:0] output_a ; output [15:0] output_b ; output output_c ; 一致的 begin end 书写方式always 中,一定要用begin end 区分,格式和代码风格统一如下: always @ (postedge clk or negedge rst_n) begin if (rst_n==1’b0) syn_rst |
CopyRight 2018-2019 实验室设备网 版权所有 |